package com.rui.test2;

/**
 * 基本的买票例子
 * 真正的多线程开发
 */
public class SaleTicketDemo01 {
    public static void main(String[] args) {
        //多线程操作，多个线程操作同一个资源类

        Ticket ticket = new Ticket();

        new Thread(() -> {
            for (int i = 0 ; i < 40 ; i++){
                ticket.sale();
            }
        },"A").start();

        new Thread(() -> {
            for (int i = 0 ; i < 40 ; i++){
                ticket.sale();
            }
        },"B").start();

        new Thread(() -> {
            for (int i = 0 ; i < 40 ; i++){
                ticket.sale();
            }
        },"C").start();
    }
}
